<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script>
    
    function  num(array){
        var len = array.length
        for(i = 0;i<len - 1;i++){
            for(j=0;j<len-1-i;j++){
                if(array[j]>array[j+1]){
                var temp
                temp = array[j]
                array[j] = array[j+1]
                array[j+1] = temp
                }
                
            }
        }
        return array
    }
    var result = num([3,8,5,1,7])
    document.write(result)
    </script>
</body>
</html>